/*
 * @Author: 'zhangkeqq' '2211709169@qq.com'
 * @Date: 2025-07-29 18:05:12
 * @LastEditors: 'zhangkeqq' '2211709169@qq.com'
 * @LastEditTime: 2025-07-30 13:54:46
 * @FilePath: \vue3-admin-node\vue3-admin\src\api\product\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import instance from '@/http/index'
import type {createProductForm,applyOutProductForm,auditProductForm} from './type'
//统一管理接口
enum API{
    CREATEPRODUCT_URL = '/pro/createProduct',
    DELETEPRODUCT_URL = '/pro/deleteProduct',
    EDITPRODUCT_URL = '/pro/editProduct',
    GETPRODUCTLIST_URL = '/pro/getProductList',
    APPLYOUTPRODUCT_URL = '/pro/applyOutProduct',
    APPLYPRODUCTLIST_URL = '/pro/applyProductList',
    WITHDRAEAPPLYPRODUCT_URL = '/pro/withdrawApplyProduct',
    AUDITPRODUCT_URL_URL = '/pro/auditProduct',
    SEARCHPRODUCTFORID_URL = '/pro/searchProductForId',
    SEARCHPRODUCTFORAPPLYID_URL = '/pro/searchProductForApplyId',
    SEARCHPRODUCTFOROUTID_URL = '/pro/searchProductForOutId',
    GETPRODUCTLENGTH_URL = '/pro/getProductLength',
    GETAPPLYPRODUCTLENGTH_URL = '/pro/getApplyProductLength',
    AUDITPRODUCTLIST_URL = '/pro/auditProductList',
    GETOUTPRODUCTLENGTH_URL = '/pro/getOutProductLength',
    RETURNPRODUCTLISTDATA_URL = '/pro/returnProductListData',
    RETURNAPPLYPRODUCTLISTDATA_URL = '/pro/returnApplyProductListData',
    RETURNPUTPRODUCTLISTDATA_URL = '/pro/returnOutProductListData',
}

//创建产品
export const createProduct = (data:createProductForm)=>{
    return instance.post(API.CREATEPRODUCT_URL,data)
}
// 删除产品
export const deleteProduct = (id:number)=>{
    return instance.post(API.DELETEPRODUCT_URL,{id})
}
// 编辑产品信息
export const editProduct = (data:createProductForm)=>{
    return instance.post(API.EDITPRODUCT_URL,data)
}
// 获取产品列表
export const getProductList = ()=>{
    return instance.post(API.GETPRODUCTLIST_URL)
}
// 产品申请出库
export const applyOutProduct = (data:applyOutProductForm)=>{
    return instance.post(API.APPLYOUTPRODUCT_URL,data)
}
//产品审核列表
export const applyProductList = ()=>{
    return instance.post(API.APPLYPRODUCTLIST_URL)
}
//对产品进行撤回申请
export const withdrawApplyProduct = (id:number)=>{
    return instance.post(API.WITHDRAEAPPLYPRODUCT_URL,{id})
}
//产品审核
export const auditProduct = (data:auditProductForm)=>{
    return instance.post(API.AUDITPRODUCT_URL_URL,data)
}
// 通过入库编号对产品进行搜索 searchProductForId
export const searchProductForId = (product_id:number | string)=>{
    return instance.post(API.SEARCHPRODUCTFORID_URL,{product_id})
}
// 通过出库申请编号对产品进行搜索
export const searchProductForApplyId = (product_out_id:number | string)=>{
    return instance.post(API.SEARCHPRODUCTFORAPPLYID_URL,{product_out_id})
}
// 通过出库编号对产品进行搜索
export const searchProductForOutId = (product_out_id:number | string) => {
    return instance.post(API.SEARCHPRODUCTFOROUTID_URL,{product_out_id})
}
// 获取产品总数
export const getProductLength = () => {
      return instance.post(API.GETPRODUCTLENGTH_URL)
}

// 获取申请出库产品总数
export const getApplyProductLength = () => {
      return instance.post(API.GETAPPLYPRODUCTLENGTH_URL)
}
// 获取出库产品列表
export const auditProductList = () => {
      return instance.post(API.AUDITPRODUCTLIST_URL)
}
// 获取出库产品总数
export const getOutProductLength = () => {
      return instance.post(API.GETOUTPRODUCTLENGTH_URL)
}
// 监听换页返回数据  产品页面
export const returnProductListData = (pager:number) => {
    return instance.post(API.RETURNPRODUCTLISTDATA_URL,{pager})
}
// 监听换页返回数据  申请出库页面
export const returnApplyProductListData = (pager:number) => {
     return instance.post(API.RETURNAPPLYPRODUCTLISTDATA_URL,{pager})
}
// 监听换页返回数据  出库页面
export const returnOutProductListData = (pager:number) => {
    return instance.post(API.RETURNPUTPRODUCTLISTDATA_URL,{pager})
}
